import 'package:backend.core/core/domain/entities/google_play/google_play_one_time_purchased_item_transaction.dart';
import 'package:backend.core/core/domain/entities/google_play/google_play_transaction_revocation_info.dart';
import 'package:backend.purchases/domain/entities/google_play_api/google_play_api_purchased_item.dart';

abstract class CreateGooglePlayOneTimePurchasedItemTransactionFromApiOne {
  GooglePlayOneTimePurchasedItemTransaction call({
    required GooglePlayApiOneTimePurchasedItem apiOneTimePurchasedItem,
    required String googlePlayUserId,
    required String purchaseToken,
    required String purchaseItemSku,
    required GooglePlayTransactionRevocationInfo? revocationInfo,
  });
}

class CreateGooglePlayOneTimePurchasedItemTransactionFromApiOneImpl
    implements CreateGooglePlayOneTimePurchasedItemTransactionFromApiOne {
  const CreateGooglePlayOneTimePurchasedItemTransactionFromApiOneImpl();

  @override
  GooglePlayOneTimePurchasedItemTransaction call({
    required GooglePlayApiOneTimePurchasedItem apiOneTimePurchasedItem,
    required String googlePlayUserId,
    required String purchaseToken,
    required String purchaseItemSku,
    required GooglePlayTransactionRevocationInfo? revocationInfo,
  }) {
    return GooglePlayOneTimePurchasedItemTransaction(
      orderId: apiOneTimePurchasedItem.orderId,
      purchaseItemSku: purchaseItemSku,
      purchaseToken: purchaseToken,
      googlePlayUserId: googlePlayUserId,
      test: apiOneTimePurchasedItem.test,
      promotional: apiOneTimePurchasedItem.promotional,
      time: apiOneTimePurchasedItem.transactionTime,
      revocationInfo: revocationInfo,
    );
  }
}
